<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="创建人" prop="createBy">
        <el-input
          v-model="queryParams.createBy"
          placeholder="请输入创建人"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="创建时间">
        <el-date-picker
          v-model="createTime"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-table v-loading="loading"
      row-key="key"
     :data="roleList" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" :height="tableHeight + 30">
        <el-table-column
          label="用户名"
          prop="customerName"
        />
        <el-table-column
          label="案件名称"
          prop="caseName"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="文档名称"
          prop="filename"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="所属案件"
          prop="caseName"
          :show-overflow-tooltip="true"
          width="150"
        />
        <el-table-column
          label="创建人"
          prop="createBy"
          :show-overflow-tooltip="true"
          width="90"
        />
        <el-table-column label="创建时间" prop="createTime" width="150" />
        <el-table-column
          label="操作"
          align="center"
          width="100"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope" v-if="scope.row.filename">
            <el-button
              size="mini"
              type="text"
              @click="ondownload(scope.row)"
              v-hasPermi="['manage:download']"
              >下载</el-button
            >
          </template>
   
    </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { attachmentTree } from "@/api/met";
import { download } from "@/api/case/case";

export default {
  name: "sealmanage",
  dicts: ["sys_normal_disable"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      total: 0,
      // 角色表格数据
      roleList: [],
      createTime: [], //搜索时间
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // createBy: undefined,
        // orderByColumn: "updateTime",
        // isAsc: "desc",
      },
    };
  },
  created() {
    this.getList();
  },
  computed: {
    tableHeight() {
      return this.$store.state.app.clientHeight;
    },
  },
  methods: {
    formatter(row) {
      switch (row.roleSort) {
        case 1:
          return "正常";
        case 2:
          return "不正常";
        default:
          return row.roleSort;
      }
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      attachmentTree(this.addDateRange(this.queryParams, this.createTime)).then(
        (response) => {
          this.roleList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.createTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    //下载
    ondownload(row, type) {
      let resource = `${row.url}`;
      this.$download.resource(resource);
    },
  },
};
</script>
